package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xmy.cultivate.entity.*;
import com.xmy.cultivate.entity.views.RenewClassRecord;
import com.xmy.cultivate.mapper.GradeMapper;
import com.xmy.cultivate.mapper.StaffMapper;
import com.xmy.cultivate.mapper.StudentMapper;
import com.xmy.cultivate.service.*;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.PageResult;
import com.xmy.cultivate.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/api/grade")
public class GradeController extends BaseController {

    @Autowired
    @Lazy
    AuthorityServic authorityServic;
    @Autowired
    @Lazy
    StudentMapper studentMapper;

    @Autowired
    @Lazy
    StaffMapper staffMapper;

    @Autowired
    @Lazy
    IGradeService iGradeService;

    @Autowired
    @Lazy
    GradeMapper gradeMapper;

    @Autowired
    @Lazy
    IQuarterService iQuarterService;

    @Autowired
    @Lazy
    IStudentGradeService iStudentGradeService;

    @Autowired
    @Lazy
    IOrganizationService iOrganizationService;

    @Autowired
    ISchoolQuarterService iSchoolQuarterService;


    @GetMapping("/gradeListAll")
    @ApiOperation("班级查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherId", value = "老师id", required = false, dataType = "String"),
            @ApiImplicitParam(name = "schoolId", value = "学校id", required = false, dataType = "String"),
    })
    public Result gradeListAll(
            @RequestParam(value = "yearPart", required = false) String yearPart,
            @RequestParam(value = "quarterNum", required = false) String quarterNum,
            @RequestParam(value = "teacherId", required = false) String teacherId,
            @RequestParam(value = "schoolId", required = false) String schoolId,
            @RequestParam(value = "subjectsId", required = false) String subjectsId,
            @RequestParam(value = "yearClassId", required = false) String yearClassId,
            @RequestParam(value = "lessonType", required = false, defaultValue = "1") String lessonType) {
        Quarter quarterNow = iQuarterService.getNowQuarter();
        Integer status = 1;
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(teacherId), "teacher_id", teacherId);
        queryWrapper.inSql(StringUtils.isNotBlank(schoolId), "school_id", schoolId);
        queryWrapper.eq(StringUtils.isNotBlank(yearPart), "year_part", yearPart);
        queryWrapper.eq(StringUtils.isNotBlank(quarterNum), "quarter_num", quarterNum);
        queryWrapper.eq(StringUtils.isNotBlank(lessonType), "lesson_type", lessonType);
        queryWrapper.inSql(StringUtils.isNotBlank(yearClassId), "year_class_id", yearClassId);

        if (quarterNow.getYearPart().equals(yearPart) && quarterNow.getNum().equals(quarterNum)) {
            queryWrapper.eq("status", status);
        }

        queryWrapper.inSql(StringUtils.isNotBlank(subjectsId), "course_id", "select id from course where subjects_id = " + subjectsId);

        List<Grade> gradeList = iGradeService.list(queryWrapper);
        for (Grade grade : gradeList) {
            QueryWrapper<StudentGrade> studentGradeQueryWrapper = new QueryWrapper<>();
            studentGradeQueryWrapper.eq("grade_id", grade.getId());
            Long count = iStudentGradeService.count(studentGradeQueryWrapper);
            grade.setStudentCount(Integer.parseInt(count.toString()));
            Organization organization = iOrganizationService.getById(grade.getSchoolId());
            if (organization != null) {
                Organization organizationNew = new Organization();
                organizationNew.setId(organizationNew.getId());
                organizationNew.setName(organizationNew.getName());
                grade.setSchoolObj(organization);
            }
        }


        return new Result(Code.OK, gradeList, "");
    }


    @GetMapping("/getGradeByAu")
    @ApiOperation("获取权限下的班级列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "班级名称", required = false, dataType = "String"),
            @ApiImplicitParam(name = "schoolId", value = "校区id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "pageNum", value = "分页数目", required = false, dataType = "String"),
            @ApiImplicitParam(name = "pageSize", value = "分页尺寸", required = false, dataType = "String")
    })
    public Result getGradeByAu(@RequestParam Map reMap) {
        Integer pageNum = StringUtils.isEmpty((String) reMap.get("pageNum")) ? 1 : Integer.valueOf((String) reMap.get("pageNum"));
        Integer pageSize = StringUtils.isEmpty((String) reMap.get("pageSize")) ? 100 : Integer.valueOf((String) reMap.get("pageSize"));
        IPage<Grade> page = new Page<>(pageNum, pageSize);
        String adminId = String.valueOf(this.adminId);
        Integer laber = authorityServic.get(adminId);
        String name = (String) reMap.get("name");
        String schoolId = (String) reMap.get("schoolId");
        QueryWrapper queryWrapper = new QueryWrapper<>();
        if (laber == 1) {
            queryWrapper.eq("g.teacher_id", adminId);
        }
        if (laber == 2) {
            Staff staff = staffMapper.selectByAdminId(Long.valueOf(adminId));
            if (staff.getSchoolId().equals(schoolId) || schoolId == null) {
                queryWrapper.eq("g.school_id", staff.getSchoolId());
                ;
            } else {
                queryWrapper.eq("g.teacher_id", adminId);
                ;
            }
        }
        queryWrapper.eq("g.status", 1);
        queryWrapper.eq("g.year_part", 2023);
        queryWrapper.groupBy("g.id");
        queryWrapper.like(StringUtils.isNotBlank(name), "name", name);
        gradeMapper.selectGrade(page, queryWrapper);
        return new Result(Code.OK, new PageResult(page.getRecords(), page.getTotal(), page.getPages()), "获取班级信息成功");
    }


    @GetMapping("/notAlreadyCount")
    @ApiOperation("未排班列表")
    public Result notAlreadyCount(@RequestParam Map reMap,
                                  @RequestParam(value = "rePushType", required = false, defaultValue = "0") Integer rePushType  //0正常排班  1复刷排班
    ) {
        Integer pageNum = StringUtils.isEmpty((String) reMap.get("pageNum")) ? 1 : Integer.valueOf((String) reMap.get("pageNum"));
        Integer pageSize = StringUtils.isEmpty((String) reMap.get("pageSize")) ? 10 : Integer.valueOf((String) reMap.get("pageSize"));
        IPage<StudentGrade> page = new Page<>(pageNum, pageSize);

        String yearPart = (String) reMap.get("yearPart");
        String quarterNum = (String) reMap.get("quarterNum");
        String subjectId = (String) reMap.get("subjectId");
        //1老师，2校区老师，3校长，4校区
        String type = (String) reMap.get("type");
        //1精品课，2智能课，3刷题班
        String lessonType = (String) reMap.get("lessonType");

        String schoolId = (String) reMap.get("schoolId");
        String yearClassId = (String) reMap.get("yearClassId");


        String startResidue = (String) reMap.get("startResidue");//剩余开始课次
        String endResidue = (String) reMap.get("endResidue");//剩余结束课次

        Quarter quarterNow = iQuarterService.getNowQuarter();
        Integer isHistory = 0;//是否查看历史的，1是，0否，查看历史的要使用(整个学期)历史表

        if (StringUtils.isBlank(yearPart)) {
            yearPart = String.valueOf(quarterNow.getYearPart());
        }
        if (StringUtils.isBlank(quarterNum)) {
            quarterNum = String.valueOf(quarterNow.getNum());
        }

        if (Integer.valueOf(yearPart) <= quarterNow.getYearPart() && Integer.valueOf(quarterNum) < quarterNow.getNum()) {
            isHistory = 1;
        }

        if (StringUtils.isBlank(schoolId)) {
            if (type.equals("2")) {
                //校区老师状态，只能看自己所在校区的数据
                schoolId = this.baseSchoolIdList.stream().map(Object::toString).collect(Collectors.joining(","));
            }
        }

        List list = new ArrayList<>();
        if (lessonType.equals("1")) {
            list = iStudentGradeService.alreadyCountNew(yearPart, quarterNum, subjectId, isHistory, yearClassId, startResidue, endResidue);
//            List<StudentGrade> orderDetailList = iStudentGradeService.orderDetailList(yearPart, quarterNum, subjectId, yearClassId);
//            for (StudentGrade studentGrade : orderDetailList) {
//                HashMap hashMap = new HashMap<>();
//                Integer alreadyCount = iStudentGradeService.alreadyCount(yearPart, quarterNum, subjectId, isHistory, studentGrade.getSchoolId(), yearClassId,startResidue,endResidue);
//                Integer notAlreadyCount = iStudentGradeService.notAlreadyCount(yearPart, quarterNum, subjectId, studentGrade.getSchoolId(), yearClassId, isHistory,startResidue,endResidue);
//                if (alreadyCount == 0 && notAlreadyCount == 0) {
//                    continue;
//                }
//                hashMap.put("alreadyCount", alreadyCount);
//                hashMap.put("notAlreadyCount", notAlreadyCount);
//                hashMap.put("schoolId", studentGrade.getSchoolId());
//                hashMap.put("schoolName", studentGrade.getSchoolName());
//                list.add(hashMap);
//            }

//            根据未排班递减排序
//            Collections.sort(list, (o1, o2) -> {
//                Integer count1 = (Integer) ((HashMap) o1).get("notAlreadyCount");
//                Integer count2 = (Integer) ((HashMap) o2).get("notAlreadyCount");
//                return count2.compareTo(count1);
//            });

        }
        if (lessonType.equals("2")) {
            iStudentGradeService.notAlreadyPracticeCount(page, yearPart, quarterNum, subjectId, schoolId, lessonType, type, yearClassId);
            for (StudentGrade studentGrade : page.getRecords()) {
                HashMap hashMap = new HashMap<>();
                hashMap.put("totalCount", studentGrade.getTotalCount());
                hashMap.put("alreadyCount", studentGrade.getAlreadyCount());
                hashMap.put("notAlreadyCount", studentGrade.getNotAlreadyCount());
                hashMap.put("schoolId", studentGrade.getSchoolId());
                hashMap.put("schoolName", studentGrade.getSchoolName());
                hashMap.put("staffName", studentGrade.getStaffName());
                hashMap.put("teacherId", studentGrade.getTeacherId());
                list.add(hashMap);
            }
        } else if (lessonType.equals("3")) {
            if (rePushType == 1) {
                //复刷排班
                iStudentGradeService.callStoreAgainBrushData(yearPart, quarterNum, subjectId, yearClassId);
                //对调用存储过程调用是否成功


                list = iStudentGradeService.reBrushStudentCount(yearPart, quarterNum, subjectId, schoolId, lessonType, type, yearClassId);

     /*           for (StudentGrade studentGrade : page.getRecords()) {
                    HashMap hashMap = new HashMap<>();
                    hashMap.put("totalCount", studentGrade.getTotalCount());
                    hashMap.put("alreadyCount", studentGrade.getAlreadyCount());
                    hashMap.put("notAlreadyCount", studentGrade.getNotAlreadyCount());
                    hashMap.put("schoolId", studentGrade.getSchoolId());
                    hashMap.put("schoolName", studentGrade.getSchoolName());
                    hashMap.put("staffName", studentGrade.getStaffName());
                    hashMap.put("teacherId", studentGrade.getTeacherId());
                    list.add(hashMap);
                }*/
            } else {
                //正常排班
                iStudentGradeService.notAlreadyPracticeCount(page, yearPart, quarterNum, subjectId, schoolId, lessonType, type, yearClassId);
                for (StudentGrade studentGrade : page.getRecords()) {
                    HashMap hashMap = new HashMap<>();
                    hashMap.put("totalCount", studentGrade.getTotalCount());
                    hashMap.put("alreadyCount", studentGrade.getAlreadyCount());
                    hashMap.put("notAlreadyCount", studentGrade.getNotAlreadyCount());
                    hashMap.put("schoolId", studentGrade.getSchoolId());
                    hashMap.put("schoolName", studentGrade.getSchoolName());
                    hashMap.put("staffName", studentGrade.getStaffName());
                    hashMap.put("teacherId", studentGrade.getTeacherId());
                    list.add(hashMap);
                }
            }
        }
  /*      else {
            iStudentGradeService.notAlreadyPracticeCount(page, yearPart, quarterNum, subjectId, schoolId, lessonType, type, yearClassId);
            for (StudentGrade studentGrade : page.getRecords()) {
                HashMap hashMap = new HashMap<>();
                hashMap.put("totalCount", studentGrade.getTotalCount());
                hashMap.put("alreadyCount", studentGrade.getAlreadyCount());
                hashMap.put("notAlreadyCount", studentGrade.getNotAlreadyCount());
                hashMap.put("schoolId", studentGrade.getSchoolId());
                hashMap.put("schoolName", studentGrade.getSchoolName());
                hashMap.put("staffName", studentGrade.getStaffName());
                hashMap.put("teacherId", studentGrade.getTeacherId());
                list.add(hashMap);
            }
        }*/

        return new Result(Code.OK, new PageResult(list, page.getTotal(), page.getPages()), "获取未排班列表成功");
    }

    @GetMapping("/notAlready")
    @ApiOperation("未排班详情")
    public Result notAlready(@RequestParam Map<String, String> reMap,
                             @RequestParam(value = "rePushType", required = false, defaultValue = "0") Integer rePushType  //0正常排班  1复刷排班
    ) {
        int pageNum = StringUtils.isBlank(reMap.get("pageNum")) ? 1 : Integer.parseInt(reMap.get("pageNum"));
        int pageSize = StringUtils.isBlank(reMap.get("pageSize")) ? 10 : Integer.parseInt(reMap.get("pageSize"));
        IPage<StudentGrade> page = new Page<>(pageNum, pageSize);

        String yearPart = reMap.get("yearPart");
        String quarterNum = reMap.get("quarterNum");
        String subjectId = reMap.get("subjectId");
        String schoolId = reMap.get("schoolId");
        String teacherId = reMap.get("teacherId");
        String lessonType = reMap.get("lessonType");//1精品课，2智能课，3刷题班
        String yearClassId = reMap.get("yearClassId");
        String detailType = reMap.get("detailType");// 1总人数 2已排班 3未排班
        String startResidue = reMap.get("startResidue");//剩余开始课次
        String endResidue = reMap.get("endResidue");//剩余结束课次
        String yearAndQuarter = reMap.get("yearAndQuarter");//异常年份学期

        Quarter quarterNow = iQuarterService.getNowQuarter();
        Integer isHistory = 0;//是否查看历史的，1是，0否，查看历史的要使用(整个学期)历史表

        if (Integer.valueOf(yearPart) <= quarterNow.getYearPart() && Integer.valueOf(quarterNum) < quarterNow.getNum()) {
            isHistory = 1;
        }
        if (StringUtils.isBlank(yearPart)) {
            yearPart = String.valueOf(quarterNow.getYearPart());
        }
        if (StringUtils.isBlank(quarterNum)) {
            quarterNum = String.valueOf(quarterNow.getNum());
        }

        if (detailType.equals("1")) {
            if (lessonType.equals("1")) {
                iStudentGradeService.alreadyAllStudent(page, yearPart, quarterNum, subjectId, schoolId, yearClassId, String.valueOf(isHistory), startResidue, endResidue);
            } else {

            }
        } else if (detailType.equals("2")) {
            if (lessonType.equals("1")) {
                iStudentGradeService.alreadyStudent(page, yearPart, quarterNum, subjectId, schoolId, yearClassId, String.valueOf(isHistory), startResidue, endResidue);
            } else {

            }
        } else if (detailType.equals("3")) {
            if (lessonType.equals("1")) {
                iStudentGradeService.notAlreadyStudent(page, yearPart, quarterNum, subjectId, schoolId, yearClassId, isHistory, startResidue, endResidue,yearAndQuarter);
            }
            if (lessonType.equals("2")) {
                iStudentGradeService.notAlreadyPracticeStudent(page, yearPart, quarterNum, subjectId, teacherId, schoolId, lessonType, yearClassId);
            } else if (lessonType.equals("3")) {
                if (rePushType == 0) {
                    iStudentGradeService.notAlreadyPracticeStudent(page, yearPart, quarterNum, subjectId, teacherId, schoolId, lessonType, yearClassId);
                } else if (rePushType == 1) {
                    iStudentGradeService.callStoreAgainBrushData(yearPart, quarterNum, subjectId, yearClassId);
                    iStudentGradeService.notAlreadyBrushStudentDetail(page, yearPart, quarterNum, subjectId, teacherId, schoolId, lessonType, yearClassId);
                }

            }
//            else {
//                iStudentGradeService.notAlreadyPracticeStudent(page, yearPart, quarterNum, subjectId, teacherId, schoolId, lessonType, yearClassId);
//            }
        }

        List<HashMap<String, Object>> list = new ArrayList<>();
        for (StudentGrade studentGrade : page.getRecords()) {
            HashMap<String, Object> hashMap = new HashMap<>();
            if (lessonType.equals("1")) {
                hashMap.put("studentName", studentGrade.getStudentName());
            } else {
                hashMap.put("studentName", studentMapper.getNameAndRemarkById(studentGrade.getStudentId()).getName());
            }
            hashMap.put("subjectId", studentGrade.getSubjectsId());
            hashMap.put("schoolName", studentGrade.getSchoolName());
            hashMap.put("yearClassId", studentGrade.getYearClassId());
            hashMap.put("residueCourseCount", studentGrade.getResidueCourseCount());
            hashMap.put("yearAndQuarter", studentGrade.getYearAndQuarter());
            hashMap.put("handleDate", studentGrade.getHandleDate());
            list.add(hashMap);
        }
        return new Result(Code.OK, new PageResult<>(list, page.getTotal(), page.getPages()), "获取未排班详情成功");
    }

    @GetMapping("/fullGradeList")
    @ApiOperation("满班率列表")
    public Result fullGradeList(@RequestParam Map<String, String> reMap) {
        String yearPart = reMap.get("yearPart");
        String quarterNum = reMap.get("quarterNum");
        String subjectId = reMap.get("subjectId");
        String schoolId = reMap.get("schoolId");
        String yearClassId = reMap.get("yearClassId");
        String date = reMap.get("date");
        String type = reMap.get("type");
        String classTypeId = reMap.get("classTypeId");
        String isDetails = reMap.get("isDetails");
        String teamId = reMap.get("teamId");

        if (StringUtils.isNotBlank(date)) {
            date += " 23:59:59";
        }

        if (StringUtils.isBlank(type)) {
            type = "1";
        }

        List<Grade> gradeList = new ArrayList<>();

        if (type.equals("5")) {
            gradeList = iStudentGradeService.getGradeFloatTeamList(yearPart, quarterNum, yearClassId, classTypeId, subjectId, schoolId, isDetails, date, teamId);
        } else {

            if (StringUtils.isBlank(schoolId)) {
                if (type.equals("2")) {
                    //校区老师状态，只能看自己所在校区的数据
                    schoolId = this.baseSchoolIdList.stream().map(Object::toString).collect(Collectors.joining(","));
                }
            }

            gradeList = iStudentGradeService.getGradeFloatList(yearPart, quarterNum, yearClassId, classTypeId, subjectId, schoolId, type, date);

            if (type.equals("6") && StringUtils.isBlank(schoolId)) {
                List<Grade> collectList = new ArrayList<>();

                QueryWrapper queryWrapper = new QueryWrapper<>();
                queryWrapper.eq("year_part", yearPart);
                queryWrapper.eq("quarter_num", quarterNum);
                queryWrapper.eq("pid", 0);
                List<SchoolQuarter> schoolQuarterList = iSchoolQuarterService.list(queryWrapper);

                for (SchoolQuarter schoolQuarter : schoolQuarterList) {
                    Grade arrivalRate = new Grade();
                    arrivalRate.setSchoolId(schoolQuarter.getSchoolId());
                    arrivalRate.setSchoolName(schoolQuarter.getSchoolName());
                    arrivalRate.setSchoolPid(schoolQuarter.getPid());
                    arrivalRate.setFullCount(0);
                    arrivalRate.setStudentCount(0);

                    collectList.add(arrivalRate);
                }

                for (Grade arrivalRate : collectList) {
                    List<Grade> childRates = new ArrayList<>();
                    for (Grade arrivalRateChild : gradeList) {
                        if (arrivalRate.getSchoolId().equals(arrivalRateChild.getSchoolId()) || arrivalRate.getSchoolId().equals(arrivalRateChild.getSchoolPid())) {
                            childRates.add(arrivalRateChild);
                            arrivalRate.setFullCount(arrivalRate.getFullCount() + arrivalRateChild.getFullCount());
                            arrivalRate.setStudentCount(arrivalRate.getStudentCount() + arrivalRateChild.getStudentCount());
                        }
                    }
                    arrivalRate.setChildren(childRates);
                }

                gradeList = collectList;
            }

        }


        return new Result(Code.OK, gradeList, "获取满班率列表成功");
    }

    @GetMapping("/fullGradeListDetails")
    @ApiOperation("满班率详情")
    public Result fullGradeListDetails(@RequestParam Map<String, String> reMap) {
        int pageNum = StringUtils.isBlank(reMap.get("pageNum")) ? 1 : Integer.parseInt(reMap.get("pageNum"));
        int pageSize = StringUtils.isBlank(reMap.get("pageSize")) ? 10 : Integer.parseInt(reMap.get("pageSize"));
        IPage<Grade> page = new Page<>(pageNum, pageSize);

        String yearPart = reMap.get("yearPart");
        String quarterNum = reMap.get("quarterNum");
        String subjectId = reMap.get("subjectId");
        String schoolId = reMap.get("schoolId");
        String yearClassId = reMap.get("yearClassId");
        String teacherId = reMap.get("teacherId");
        String gradeId = reMap.get("gradeId");
        String date = reMap.get("date");
        String classTypeId = reMap.get("classTypeId");
        String type = reMap.get("type");
        String teamId = reMap.get("teamId");

        if (StringUtils.isNotBlank(date)) {
            date += " 23:59:59";
        }

        if (StringUtils.isNotBlank(type) && type.equals("5")) {
            iStudentGradeService.getGradeFloatTeamDetailsList(page, yearPart, quarterNum, yearClassId, classTypeId, subjectId, schoolId, date, teamId, teacherId, gradeId);
        } else {
            iStudentGradeService.getGradeFloatDetails(page, yearPart, quarterNum, yearClassId, classTypeId, subjectId, schoolId, gradeId, teacherId, date);
        }

        return new Result(Code.OK, new PageResult<>(page.getRecords(), page.getTotal(), page.getPages()), "获取满班率详情成功");
    }

    @GetMapping("/getTeacherForSubjects")
    public Result getTeacherForSubjects(@RequestParam(value = "yearPart", required = false) Integer yearPart,
                                        @RequestParam(value = "quarterNum", required = false) Integer quarterNum,
                                        @RequestParam(value = "schoolId", required = false) String schoolId,
                                        @RequestParam(value = "subjectsId", required = false) String subjectsId,
                                        @RequestParam(value = "yearClassId", required = false) String yearClassId) {

        return null;

    }


    @GetMapping("/adjustGradeList")
    @ApiOperation("需调班列表")
    public Result adjustGradeList(@RequestParam(value = "yearPart", required = false) Integer yearPart,
                                  @RequestParam(value = "quarterNum", required = false) Integer quarterNum,
                                  @RequestParam(value = "type", required = false) Integer type,
                                  @RequestParam(value = "schoolId", required = false) String schoolId,
                                  @RequestParam(value = "yearClassId", required = false) String yearClassId,
                                  @RequestParam(value = "classTypeId", required = false) String classTypeId,
                                  @RequestParam(value = "subjectsId", required = false) String subjectsId,
                                  @RequestParam(value = "name", required = false) String name,
                                  @RequestParam(value = "teamId", required = false) String teamId,
                                  @RequestParam(value = "classify", required = false) String classify,
                                  @RequestParam(value = "trackType", required = false) String trackType,
                                  @RequestParam(value = "isDetails", defaultValue = "0", required = false) Integer isDetails
    ) {
        List<StudentGrade> studentGradeList = iStudentGradeService.adjustGradeList(yearPart, quarterNum, type, schoolId, yearClassId, classTypeId, subjectsId, name, teamId, classify, trackType, isDetails);
        return new Result(Code.OK, studentGradeList, Code.GET_OK_MSG);
    }

    @GetMapping("/adjustGradeDetails")
    @ApiOperation("需调班详情")
    public Result adjustGradeDetails(@RequestParam(value = "pageNum", defaultValue = "1", required = false) Integer pageNum,
                                     @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
                                     @RequestParam(value = "yearPart", required = false) Integer yearPart,
                                     @RequestParam(value = "quarterNum", required = false) Integer quarterNum,
                                     @RequestParam(value = "type", required = false) Integer type,
                                     @RequestParam(value = "detailType", required = false) Integer detailType,
                                     @RequestParam(value = "schoolId", required = false) String schoolId,
                                     @RequestParam(value = "yearClassId", required = false) String yearClassId,
                                     @RequestParam(value = "classTypeId", required = false) String classTypeId,
                                     @RequestParam(value = "subjectsId", required = false) String subjectsId,
                                     @RequestParam(value = "teacherId", required = false) String teacherId,
                                     @RequestParam(value = "name", required = false) String name,
                                     @RequestParam(value = "teamId", required = false) String teamId,
                                     @RequestParam(value = "classify", required = false) String classify,
                                     @RequestParam(value = "trackType", required = false) String trackType
    ) {
        IPage<Grade> page = new Page<>(pageNum, pageSize);
        iStudentGradeService.adjustGradeDetails(page, yearPart, quarterNum, schoolId, yearClassId, type, classTypeId, name, teamId, classify, trackType, detailType, subjectsId, teacherId);
        return new Result(Code.OK, new PageResult<>(page.getRecords(), page.getTotal(), page.getPages()), Code.GET_OK_MSG);
    }


}
